Re: [amibroker] BuySignal

 

Hi,
I still can not solve my doubt.
I can identify on the chart: 
1) the highest price (myH) of the first bar when there is gap up; 
2) the lowest price (myL) of the first bar when low gap down; 
3) the last bar of the period of interest for open trade.

I can not identify the input signal (buysignal / shortsignal): price > myH of the first bar / price < myL of the first bar.

I ask the more experienced afl guidance where I can find examples to help me solve the problem.

Best Regards.

////////////////////////the code/////////////////////////////////

IsNewDay = Day()!=Ref(Day(),-1);
UpGap = Open < Close AND Open > Ref(High,-1) AND Low > Ref(High,-1) AND IsNewDay;//identifico gap
DownGap = Open > Close AND Open < Ref(Low,-1) AND High < Ref(Low,-1) AND IsNewDay;

//to identify timestamps of the bars
tn = TimeNum();
// define start/end hours in TimeNum format
StartTime = 091459;
Endtime = 105959;
EndTradeDay = tn >= 174459;

// these conditions are true when TimeNum of the bar equals startime/endtime
StartBar = tn == StartTime;
EndBar = tn == Endtime;

// on the start bar we read the value of highest high or lowest low since the start bar
myH = IIf(UpGap, ValueWhen( StartBar, HighestSince( StartBar, High ) ),0);
myL = IIf(DownGap, ValueWhen( StartBar, LowestSince( StartBar, Low ) ), 0);
BuySignal = 0;
ShrtSignal = 0;

j = 0;
for ( i = 1; i < 8; i++)
{
 if( C[ i ] > myH[ j ] )
 {
  BuySignal[ i ] = 1;
  
 }
 if ( C[ i ] < myL[ j ] )
 {
  ShrtSignal[ i ] = 1;
  
 }
    
}

BuyCondition = IsNewDay AND UpGap AND tn <= EndTime;
Buy = BuyCondition AND BuySignal;
ShrtCondition = IsNewDay AND DownGap AND tn <= EndTime;
Short = ShrtCondition AND ShrtSignal;
Sell = Cover = EndTradeDay;

PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Short*shapeDownArrow,colorRed,0,High);
PlotShapes( IIf( myH , shapeDigit1 + shapePositionAbove,shapeNone),colorBlack );
PlotShapes( IIf( myL , shapeDigit2 + shapePositionAbove,shapeNone),colorBlack );
PlotShapes( IIf(LastBar, shapeDigit4 + shapePositionAbove, shapeNone),colorBlue );
Plot( Close,"Price",colorBlack,styleCandle);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Em Segunda-feira, 25 de Julho de 2016 15:02, "Edilson Santos edilson.floriano@yahoo.com.br [amibroker]" <amibroker@yahoogroups.com> escreveu:


 


Thank you.
Like you, I also suffer to interpret the afl code;
I will study what you proposed and then make any comments.
The GapUP () function does not meet my goal.

Best Regards.
Edilson


Em Segunda-feira, 25 de Julho de 2016 14:00, "brandon.richard03@yahoo.com [amibroker]" <amibroker@yahoogroups.com> escreveu:


 
I gave your AFL a shot and I'm horrible at interpreting AFL most the time so not quite sure what you we're exactly doing but from my understanding of your goal, here's a simple snippet of entering on an gap up.

I'm not familiar with the use of GapUp() because from my reading of the function, it refers to it in days so not sure if it's intended for bars? Also I know from a previous experience that it is kind of a forward bias as it references the bars low and previous bars high so you need to have a entry delay if using it.

//Periodicity set to 15 minute in settings

UpGap = TimeFrameGetPrice("H",inDaily,-1) < ValueWhen(Day()!=Ref(Day(),-1),L);
// Second half of statement means low of first candle of day is greater then previous days high,
// could also use Open as a value so open of candle is greater then previous days high.

// identifies the high and low of the first candle of the day
HighOfFirstBar=valuewhen(day()!=ref(day(),-1),H);
LowOfFirstBar=valuewhen(day()!=ref(day(),-1),L);

TimeOfDayOkay= TimeNum() < 120000;// Event happens before noon

Buy = Cross(H,HighofFirstBar) AND TimeOfDayOkay AND UpGAP;
Sell = TimeNum() == 154459;//selling at closing

BuyPrice = Max(HighOfFirstBar,O);// entry price is high of first bar or open of current candle(which ever is higher)
SellPrice = Close;//sell price is close of last candle

I could be way off from your goal and this is just a snippet off a the GapUp side, if its on track you should be able to fill in the rest of your system.




__._,_.___

Posted by: Edilson Santos <edilson.floriano@yahoo.com.br>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (5)

Save time and get your email on the go with the Yahoo Mail app
Get the beautifully designed, lighting fast, and easy-to-use Yahoo Mail today. Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___


EmoticonEmoticon