1. Welcome back! Thank you for being a part of this Traders Community. Let's discuss and share :)
    Selamat datang kembali! Trimakasih telah menjadi bagian dari Komunitas Trader ini. Mari berdiskusi dan berbagi :)
    Dismiss Notice

Tutorial (ASK) Bagaimana membuat fungsi jumlah signal ?

Discussion in 'Belajar MQL dari Nol' started by Johan182, 14 Jun 2020.

  1. Johan182

    Johan182 New Member

    Equity
    Credit
    Ref Point
    Bagaimana membuat fungsi untuk cek jumlah signal yang muncul?
    Misalnya cek jumlah signal PSAR
    //check signal SAR
    int QnPSar(int shift=0){
    int result=0;
    double pSar = iSAR (NULL,0,0.01,0.02,shift);
    double pSar1 = iSAR (NULL,0,0.01,0.02,1);
    if(pSar<Low[shift] && pSar1>High[1] ) result =1; //psar dibawah c0 dan diatas c1 signal sell
    if(pSar>High[shift] && pSar1<Low[1] ) result =2; //psar diatas c0 dan dibawah c1 signal buy
    return(result);}

    QnJumlahSignal(Signal yang mau dihitung)

    //Contoh
    { if ( QnJumlahSignal ( QnPSar()==1 ) ==2 )QnBuy() ; } //menghitung signal QnPSar()==1 jika muncul 2x maka fungsi QnBuy dijalankan
     
  2. Noir_

    Noir_ New Member

    Equity
    Credit
    Ref Point
    Code:
    int shift=10; //jumlah candle yang mau dihitung
    
    int SignalBuy=0;
    int SignalSell=0;
      for(int i=shift; i>=0; i--)
         {
         if(iSAR (NULL,PERIOD_CURRENT,0.02,0.2,i)>High[i])
          SignalSell++; //Hitung Jumlah Psar Sell
         if(iSAR (NULL,PERIOD_CURRENT,0.02,0.2,i)<Low[i])
          SignalBuy++; //Hitung Jumlah Psar Buy
         }
      Comment("Jumlah Buy : "+IntegerToString(SignalBuy,0)+"\n"+"Jumlah Sell : "+IntegerToString(SignalSell,0));
     
    Last edited: 14 Jun 2020

Share This Page