Attachments forums

List of attachments posted on this forum.


All files on forums: 135714

Re: Coding Help

schemman, Tue Nov 19, 2019 10:01 am

Dear experts,

I was trying to code a simple EA with the "Super smoothed average trend 1.2" by Jimmy, which is an indicator in the Top 10 NRP indicators list in here (attached below for ease of access). The idea is to make a buy order when the indicator turns Green (by default) and sell order vice versa. I was trying to find the indicator values using iCustom function during backtesting as shown below.

Code: Select all

#include <stdlib.mqh>

extern int                AvgPeriod1 = 34;
extern ENUM_APPLIED_PRICE AvgPrice1 = PRICE_CLOSE;

void OnTick()
{  
   double CustomIndi0 = iCustom(Symbol(), 15, "Super smoothed average trend 1.2", AvgPeriod1, AvgPrice1, 0, 1);
   Print("The value of Indicator Buffer 0 is: ", CustomIndi0);
   double CustomIndi1 = iCustom(Symbol(), 15, "Super smoothed average trend 1.2", AvgPeriod1, AvgPrice1, 1, 1);
   Print("The value of Indicator Buffer 1 is: ", CustomIndi1);
   double CustomIndi2 = iCustom(Symbol(), 15, "Super smoothed average trend 1.2", AvgPeriod1, AvgPrice1, 2, 1);
   Print("The value of Indicator Buffer 2 is: ", CustomIndi2);
   double CustomIndi3 = iCustom(Symbol(), 15, "Super smoothed average trend 1.2", AvgPeriod1, AvgPrice1, 3, 1);
   Print("The value of Indicator Buffer 3 is: ", CustomIndi3);
   double CustomIndi4 = iCustom(Symbol(), 15, "Super smoothed average trend 1.2", AvgPeriod1, AvgPrice1, 4, 1);
   Print("The value of Indicator Buffer 4 is: ", CustomIndi4);
   double CustomIndi5 = iCustom(Symbol(), 15, "Super smoothed average trend 1.2", AvgPeriod1, AvgPrice1, 5, 1);
   Print("The value of Indicator Buffer 5 is: ", CustomIndi5);
   double CustomIndi6 = iCustom(Symbol(), 15, "Super smoothed average trend 1.2", AvgPeriod1, AvgPrice1, 6, 1);
   Print("The value of Indicator Buffer 6 is: ", CustomIndi6);
   double CustomIndi7 = iCustom(Symbol(), 15, "Super smoothed average trend 1.2", AvgPeriod1, AvgPrice1, 7, 1);
   Print("The value of Indicator Buffer 7 is: ", CustomIndi7);
   double CustomIndi8 = iCustom(Symbol(), 15, "Super smoothed average trend 1.2", AvgPeriod1, AvgPrice1, 8, 1);
   Print("The value of Indicator Buffer 8 is: ", CustomIndi8);
 } 
When I execute this, it returns Empty_Value in Line Index 2 and 3, while the rest of them are zero. I tried using backtest data where the indicator shows green, as well as red, but the return values did not change at all.

Any help would be highly appreciated. Thank you very much for your time.
All files in topic