Once you set a=1 or b=1 are they ever set back to zero?
you really shouldn't be using an int b!=1 b=1, you should be using bool b=true;
next time post all the code. we have no idea where you set a=0 or what limit is.
Hello thank you for your reply.
I set a = 0 and b = 0 at the beginning of the code.
I wrote this code because I had too many signals (an arrow on all the candles).
I'll try with "bool" and I'll post all the code
thank you very much
I set a = 0 and b = 0 at the beginning of the code.
I wrote this code because I had too many signals (an arrow on all the candles).
I'll try with "bool" and I'll post all the code
thank you very much
I inserted "bool" in my code, but I do not know if I wrote it correctly.
I made a screenshot (too many signals).
my code:
#property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Green #property indicator_width1 2 #property indicator_color2 Red #property indicator_width2 2 //--- input parameters extern int barsToProcess=1000; //--- buffers double buff1[]; double buff2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(2); SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,225); SetIndexBuffer(0,buff1); SetIndexEmptyValue(0,0.0); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,226); SetIndexBuffer(1,buff2); SetIndexEmptyValue(1,0.0); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { bool a = false; int limit; int counted_bars=IndicatorCounted(); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; double Var1 = iCustom(NULL, 0, "BTrendv1", 20,3, 0, 0); //up double Var2 = iCustom(NULL, 0, "Btrendv1", 20,3, 1, 0); //down double Var3 = iCustom(NULL, 0, "Sonar", 9,30, 0, 0); double Var4 = iCustom(NULL, 0, "Damiani_volatmeter", 13,20,40,100,1.4,TRUE,2000,0,0); //down double Var5 = iCustom(NULL, 0, "Damiani_volatmeter", 13,20,40,100,1.4,TRUE,2000,2,0);//up double Var6 = iCCI(NULL,0,14,PRICE_TYPICAL,0); double sig_buy = Var2>Var1 && Var3>Var2 && (Var5>Var4 && Var6>0); double sig_sell = Var2<Var1 && Var3<Var2 && (Var5>Var4 && Var6<0); // --------------------------------------------------------------------- for(int i=0;i<limit;i++) { if ( sig_buy == true) { buff1[i] = Low[i+1] - 25*Point; a = true; } if ( sig_sell == true) { buff2[i] = High[i+1] + 25*Point; a = true; } } return(0); } //+------------------------------------------------------------------+
So you only want to show the arrow when it changes from up to down or down to up ? You need to remember its current state and only set a value for buff1[i] and buiff2[i] when the state changes. So use a = true for buff1 and a = false for buff2 . . . then check the value of a before you set the buff1 value, if ( sig_buy == true && !a) and visa versa for buff2 . . . . give it a go, if you need more help ask . .
RaptorUK:
So you only want to show the arrow when it changes from up to down or down to up ? You need to remember its current state and only set a value for buff1[i] and buiff2[i] when the state changes. So use a = true for buff1 and a = false for buff2 . . . then check the value of a before you set the buff1 value, if ( sig_buy == true && !a) and visa versa for buff2 . . . . give it a go, if you need more help ask . .
So you only want to show the arrow when it changes from up to down or down to up ? You need to remember its current state and only set a value for buff1[i] and buiff2[i] when the state changes. So use a = true for buff1 and a = false for buff2 . . . then check the value of a before you set the buff1 value, if ( sig_buy == true && !a) and visa versa for buff2 . . . . give it a go, if you need more help ask . .
I love you RaptorUK thank you very much!!!
Why isn't a=0 INSIDE the loop?
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
I joined this forum because I need your help.
I tried to write a code but it does not work well.
The problem: the indicator does not work anymore after taking the signals (buy, sell).
I do not know where I made the mistake.
Can you help me?
my code: