my first custom indicator crashes my terminal... please help - page 2

 

wow i am going to hit the books again and start over.... i have become really confused....

thanks guys for our help so far i will post my next attempt soon and i will probably have some more questions but now i am not even sure what to ask.

 

  1. for(i=limit;i>=0;i--)
    double Ma01=iMA(NULL,0,MA_Period,0,MODE_SMA,PRICE_CLOSE,i);
    double Atr01=iATR(NULL,0,ATR_Period,i);
    double Close01=(Close[i]);
    FFRI[i]=((Close01-Ma01)/Atr01);
    Where are your brackets? Indent your code properly so you can read it.
    for(i=limit;i>=0;i--)
    {
      double Ma01=iMA(NULL,0,MA_Period,0,MODE_SMA,PRICE_CLOSE,i);
      double Atr01=iATR(NULL,0,ATR_Period,i);
      double Close01=(Close[i]);
      FFRI[i]=((Close01-Ma01)/Atr01);
    }

  2. Your original while loop had no decrementation. Then you added it outside of the loop:
    while(i>=0)
    {
    double Ma01 = iMA(NULL,0,MA_Period,0,MODE_SMA,PRICE_CLOSE,i);
    double Atr01 = iATR(NULL,0,ATR_Period,i);
    double Close01 = (Close[i]);
    FFRI[i]= ( ( Close01 - Ma01 ) / Atr01);
    }
    i--;
    You had to add it inside:
    while(i>=0)
    {
      double Ma01 = iMA(NULL,0,MA_Period,0,MODE_SMA,PRICE_CLOSE,i);
      double Atr01 = iATR(NULL,0,ATR_Period,i);
      double Close01 = (Close[i]);
      FFRI[i]= ( ( Close01 - Ma01 ) / Atr01);
      i--;
    }
    

 
WHRoeder:

  1. Where are your brackets? Indent your code properly so you can read it.
  2. Your original while loop had no decrementation. Then you added it outside of the loop: You had to add it inside:


Hello WHRoeder, thanks for joining the "school this noob team", i tried what you suggested and my indicator window is still blank, i am sure the issue pertains to what Cameo suggested, i thought i had a grasp of this programming stuff but now i am lost in the sauce and starting fresh.

 

OK fellas this is where is am at...

i simplified the program to just calculate the close-the MA and it worked great. the indicator displayed on all bars in my chart and all was good

but then i added the /atr part and the only thing that displayed in my indicator window was the line for the current bar. and then a new line would appear for each new bar.

so i am really confused on the bar counting subject....

 

- Start from your last successful code & add what you need one piece at a time. compile, run, evaluate. If it's as you expected repeat the process. if not, change/delete that piece. & repeat the process. 

- Google & download : Techguy Bar Counting and Indexing Guide

 

Thanks Cameo! that bar counting guide really helped!

i have now succeeded at creating my first custom indicator!

i am gonna keep the thread open as i try to dress up the indicator and create a script based on the indicator.

thanks for your help so far guys :-)

Files:
 

Hey Fellas!

ok here is what i want to do next but i am not so sure how to go about it. i would like to program an indicator that finds the highest price reached during the swing of the momentum indicator and an MA

for example

Momentum Closes below the 100 line and a bar closes below SMA 20 what was the highest price reached from the previous low.

if someone could give me a shove i will start running.

Reason: