Re: [amibroker] BuySignal

 

Still waiting for help.
I've tried a loop, but it did not work...

///////////////////////
BuyCondition = IsNewDay AND UpGap AND TimeOK;
ShrtCondition = IsNewDay AND DownGap AND TimeOK;

j = 0;

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

Buy = BuyCondition AND BuySignal;
Short = ShrtCondition AND ShrtSignal;
/////////////////////////////////////

Best Regards,
Edilson


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


 
Hi all,

I'm trying to establish buysignal (or shortsignal) from the highest (or lowest) of the first bar of the day.

The code that was built (from many sources) and that I created is not adequately identifying disruptions (highest or lowest).

I use timestaps 15M

Could anyone help?

///////The code////////////////

//Identify newday and gap
IsNewDay = Day()!=Ref(Day(),-1);
UpGap = GapUp() AND IsNewDay;
DownGap = GapDown() AND IsNewDay;

//to identify timestamps of the bars
tn = TimeNum();
// define start/end hours in TimeNum format (timestamp)
StartTime = 091459;
EndTime = 105959;
BeginTradeDay = 092959;
EndTradeDay = tn >= 174459;
TimeOK = tn > BeginTradeDay AND tn <= EndTime;
// 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);

BuyCondition = TimeOk;
BuySignal = Cross(H, Ref(myH, -1)) OR Cross(H, Ref(myH, -2)) OR Cross(H, Ref(myH, -3)) OR Cross(H, Ref(myH, -4))
OR Cross(H, Ref(myH, -5)) OR Cross(H, Ref(myH, -6)) OR Cross(H, Ref(myH, -7));

ShrtCondition = TimeOK;
ShrtSignal = Cross(Ref(myL, -1), L) OR Cross(Ref(myL, -2), L) OR Cross(Ref(myL, -3), L) OR Cross(Ref(myL, -4), L)
OR Cross(Ref(myL, -5), L) OR Cross(Ref(myL, -6), L) OR Cross(Ref(myL, -7), L);


Buy = BuyCondition AND BuySignal;
Short = ShrtCondition AND ShrtSignal;

Sell = Cover = EndTradeDay;

nATR = 3;//Optimize("nATR", 3, 1, 5, 1);
nATRRange = 14;//Optimize("nATRRange", 14, 9, 21, 1);
ApplyStop(stopTypeTrailing, stopModePoint, nATR * ATR( nATRRange ), True, True );

//////////////////////////////////////

Best Regards
Edilson




__._,_.___

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 (2)

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