I have written a custom indicator that uses the switch of parabolic sar and awesome indicator to show me when to enter a trade, I have been trying to put the code into a EA with no luck, any help would be most appreciated.
I have tried a few ways of putting it into an EA, by copying and pasting the code while changing ExtVigTheoryBuffer to a buy orderSend command but it ends up buying multiple times on the same candle. When i try calling the custom indicator, it slows down to a snailThe indicator recalculates every pixel for each tick - use IndicatorCounted Multiple Null Bar Re-Count in Some Indicators
- Where's your EA code. Did you use Icustom or did you paste the code, forget to remove the i<Bars loop with i=0
Thank you William for such a quick reply.
I tried putting this into an EA which fails miserably :
#property indicator_separate_window // Set static height of indicator graph #property indicator_minimum -1.2 #property indicator_maximum 1.2 // Set colors for two indicators #property indicator_color1 Red extern double Step =0.09; //Parabolic setting extern double Maximum =0.2; //Parabolic setting double ExtVigTheoryBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,115); SetIndexBuffer(0,ExtVigTheoryBuffer); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { /* // Go through all the candlesticks, determine whether to buy, sell or do nothing // at each point int MaxBar, limit, counted_bars = IndicatorCounted(); //---- check for possible errors if(counted_bars < 0) return(-1); //---- the last counted bar must be re-counted if(counted_bars > 0) counted_bars--; //---- determining of the oldest bar number, starting from which // all bars will be re-counted MaxBar = Bars - 1 - T3_Period; //---- determining of the oldest bar number, starting from which // only new bars will be re-counted limit = (Bars - 1 - counted_bars); //---- initialization of null if(limit > MaxBar) { for(int bar = Bars - 1; bar >= limit; bar--) MapBuffer[bar] = 0.0; limit = MaxBar; } */ // Get difference in Awesomeness for current and previous values double aoDiff = iAO(NULL, 0, 0) - iAO(NULL, 0, 1); // If Stop and Reverse changes from above curve to below curve, // and awesomeness is "green", start buying if (iSAR(NULL, 0,Step,Maximum, 0) < iLow(NULL,0,0) && iSAR(NULL, 0, Step, Maximum, 1) > iHigh(NULL, 0, 1) && aoDiff >= 0) { int buy = OrderSend(Symbol(),OP_BUY,1,Ask,5,Ask-30*Point,Ask+50*Point,0,0,0,Green); return; } // if Stop and Reverse is changes from below the curve to above the curve // and awesomeness is "red", start selling else if (iSAR(NULL, 0,Step,Maximum, 0) > iHigh(NULL,0,0) && iSAR(NULL, 0,Step,Maximum, 1) < iLow(NULL,0,1) && aoDiff <= 0 ) { int red = OrderSend(Symbol(),OP_SELL,1,Bid,5,Bid+30*Point,Bid-50*Point,0,0,0,Red); return; } return(0); } //+------------------------------------------------------------------+
I tried to add the code from the Multiple Null Bar Re-counted with no luck so i /* */ that code as i didn't totally understand how the code worked. I feel that I have made a really basic mistake but I just can't see it.
Thanks again William
Thank you William for such a quick reply.
I tried putting this into an EA which fails miserably :
I tried to add the code from the Multiple Null Bar Re-counted with no luck so i /* */ that code as i didn't totally understand how the code worked. I feel that I have made a really basic mistake but I just can't see it.
Thanks again William
1) Your code is a indicators, and indicators are not allowed to trade.
2) the start() function is called every tick. so when your conditions are true, every tick a new order is sendet.
open editor, create a empty Expert Advisor.
-search here in the forum on how to limit the EA to trade only once per Bar.
-search how to modify the EA that it supports 4/5 digit brokers
this are the main mistakes you have made, i have not looked in detail at your code, so there maybe some other logical error, for now try to build a very basic EA, not a Indicator

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I have written a custom indicator that uses the switch of parabolic sar and awesome indicator to show me when to enter a trade, I have been trying to put the code into a EA with no luck, any help would be most appreciated.
I have tried a few ways of putting it into an EA, by copying and pasting the code while changing ExtVigTheoryBuffer to a buy orderSend command but it ends up buying multiple times on the same candle. When i try calling the custom indicator, it slows down to a snail and never enters.
How would you suggest that I test my theory? Also any criticism of the actual theory are welcome.
#property indicator_separate_window
// Set static height of indicator graph
#property indicator_minimum -1.2
#property indicator_maximum 1.2
// Set colors for two indicators
#property indicator_color1 Red
extern double Step =0.09; //Parabolic setting
extern double Maximum =0.2; //Parabolic setting
double ExtVigTheoryBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,115);
SetIndexBuffer(0,ExtVigTheoryBuffer);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
// Go through all the candlesticks, determine whether to buy, sell or do nothing
// at each point
for (int i = 0; i < Bars; i++){
// Get difference in Awesomeness for current and previous values
double aoDiff = iAO(NULL, 0, i) - iAO(NULL, 0, i+1);
// If Stop and Reverse changes from above curve to below curve,
// and awesomeness is "green", start buying
if (iSAR(NULL, 0,Step,Maximum, i) < iLow(NULL,0,i)
&& iSAR(NULL, 0, Step, Maximum, i+1) > iHigh(NULL, 0, i+1)
&& aoDiff >= 0)
{
ExtVigTheoryBuffer[i] = 1.0;
}
// if Stop and Reverse is changes from below the curve to above the curve
// and awesomeness is "red", start selling
else if (iSAR(NULL, 0,Step,Maximum, i) > iHigh(NULL,0,i)
&& iSAR(NULL, 0,Step,Maximum, i+1) < iLow(NULL,0,i+1)
&& aoDiff <= 0 )
{
ExtVigTheoryBuffer[i] = -1.0;
}
}
return(0);
}
//+------------------------------------------------------------------+