How would we know?
We dont know what the values of these variables are
if(fiy1>0&&fiy1tersi>0) { C=(fiy1tersi-fiy1)*100;
//FIRST PROGRAM extern int K=80; extern int D=10; extern int S=15; extern double A,B,C; int start() { double stoccurrM=iStochastic(Symbol(),0,K,D,S,0,0,MODE_MAIN,0); double stocprevM=iStochastic(Symbol(),0,K,D,S,0,0,MODE_MAIN,1); double stocprevprevM=iStochastic(Symbol(),0,K,D,S,0,0,MODE_MAIN,2); double stoccurrS=iStochastic(Symbol(),0,K,D,S,0,0,MODE_SIGNAL,0); double stocprevS=iStochastic(Symbol(),0,K,D,S,0,0,MODE_SIGNAL,1); double stocprevSS=iStochastic(Symbol(),0,K,D,S,0,0,MODE_SIGNAL,2); double macd=iMACD(Symbol(),0,12,26,9,0,0,0); double pmacd=iMACD(Symbol(),0,12,26,9,0,0,1); double rsi=iRSI(Symbol(),0,14,0,0); if(stoccurrS>stocprevS&&stocprevS<stocprevSS&&rsi<60&&macd<0) { A=Ask; } if(stoccurrS<stocprevS&&stocprevS>stocprevSS&&rsi>40&&macd>0) { B=Bid; if(A>0&&B>0) { C=(B-A)*100; Print(C); A=0; B=0; } } return; } //SECOND PROGRAM extern int K=80; extern int D=10; extern int S=15; int start() { double stoccurrM=iStochastic(Symbol(),0,K,D,S,0,0,MODE_MAIN,0); double stocprevM=iStochastic(Symbol(),0,K,D,S,0,0,MODE_MAIN,1); double stocprevprevM=iStochastic(Symbol(),0,K,D,S,0,0,MODE_MAIN,2); double stoccurrS=iStochastic(Symbol(),0,K,D,S,0,0,MODE_SIGNAL,0); double stocprevS=iStochastic(Symbol(),0,K,D,S,0,0,MODE_SIGNAL,1); double stocprevSS=iStochastic(Symbol(),0,K,D,S,0,0,MODE_SIGNAL,2); double macd=iMACD(Symbol(),0,12,26,9,0,0,0); double pmacd=iMACD(Symbol(),0,12,26,9,0,0,1); double rsi=iRSI(Symbol(),0,14,0,0); if(stoccurrS>stocprevS&&stocprevS<stocprevSS&&rsi<60&&macd<0) { double A=Ask; } if(stoccurrS<stocprevS&&stocprevS>stocprevSS&&rsi>40&&macd>0) { double B=Bid; if(A>0&&B>0) { double C=(B-A)*100; Print(C); A=0; B=0; } } return; }
Very Big Sorry,
Right scripts are above
i hope ;)
When you declare a double, that declaration only applies to the block of code that contains it
if(stoccurrS>stocprevS&&stocprevS<stocprevSS&&rsi<60&&macd<0) { double A=Ask; }
Outside of that block, the value is lost and you will probably have an error report from the compiler about the undeclared variable. Declare it outside of the block
double A if(stoccurrS>stocprevS&&stocprevS<stocprevSS&&rsi<60&&macd<0) { A=Ask; }
//FIRST PROGRAM extern int K=80; extern int D=10; extern int S=15; extern double A,B,C,SUMC; int start() { double stoccurrM=iStochastic(Symbol(),0,K,D,S,0,0,MODE_MAIN,0); double stocprevM=iStochastic(Symbol(),0,K,D,S,0,0,MODE_MAIN,1); double stocprevprevM=iStochastic(Symbol(),0,K,D,S,0,0,MODE_MAIN,2); double stoccurrS=iStochastic(Symbol(),0,K,D,S,0,0,MODE_SIGNAL,0); double stocprevS=iStochastic(Symbol(),0,K,D,S,0,0,MODE_SIGNAL,1); double stocprevSS=iStochastic(Symbol(),0,K,D,S,0,0,MODE_SIGNAL,2); double macd=iMACD(Symbol(),0,12,26,9,0,0,0); double pmacd=iMACD(Symbol(),0,12,26,9,0,0,1); double rsi=iRSI(Symbol(),0,14,0,0); if(stoccurrS>stocprevS&&stocprevS<stocprevSS&&rsi<60&&macd<0) { A=Ask; //-------------------------------IF YOU ADD BUY ORDER } if(stoccurrS<stocprevS&&stocprevS>stocprevSS&&rsi>40&&macd>0) { B=Bid; //-------------------------------IF YOU ADD CLOSE -BUY ORDER if(A>0&&B>0) { C=(B-A)*100; SUMC=SUMC+C; Print(SUMC); A=0; B=0; } } return; } I solved it with extern variables but i did not understand the logic. When you calculate "C " and add it one by one the result will be printingin to SUMC.And the SUMC is very big positive . With the same logic , At the "Ask" block ,if you add BUY order ,and at the "Bid" block if you CLOSE this order . Its strategy tester loses money. Logic is the same i think . // B-A =C or Closing Price of Buy -Open Price of Buy =Profit of the account. But it differs a big...And loses money.
regardless why don't you use SYMBOL_SPREAD or MODE_SPREAD instead of B-A*100
I think it is not about spreads.
It is about strategy of buy and strategy of close points differ when you use buy -close orders.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register