Amibroker Alertif

mastermind007

Well-Known Member
#11
LastValue(Ref(<VariableContainingCrossoverSignal>, -1))
 
#13
Can one add time limit in file writing function?
I tried with below but unsuccessful.

tn = TimeNum();

startTime = 091501; // start in HHMMSS format
endTime = 152700; // end in HHMMSS format

timeOK = tn >= startTime AND tn <= endTime;

fh = fopen( "C:\\Users\\Admin\\Desktop\\buysellsignals.txt", "a" );

if(fh and timeOK)
{

Thanks in advance for any guidance.
 

against_tides

Well-Known Member
#14
instead of notepad...
try
type "text by/sell">>c:\file.txt
 
#15
Use Name() in place of getchartid()
It is missing few signals (2-3 out of 40, of different scrips different signals)
I am unable to find out the reason, running it on 5 mins intraday data.

below is the code:

alreadyopenbuy1 = StaticVarGetText("alreadyopenbuy1"+Name());
alreadyopenbuy2 = StaticVarGetText("alreadyopenbuy2"+Name());

alreadyopensell1 = StaticVarGetText("alreadyopensell1"+Name());
alreadyopensell2 = StaticVarGetText("alreadyopensell2"+Name());


fh = fopen( "C:\\Users\\test\\Desktop\\tradelog.csv", "a" );

if(fh)
{

if ( (LastValue(Buy1) == True ) AND alreadyopenbuy1 == "" )
{
StaticVarSetText("alreadyopenbuy1"+Name() , "1");
StaticVarSetText("alreadyopensell1"+Name() , "");

fputs( now(1) + ","+ now(2) + "," + "BUY1" + " ," + Name() + " ," +Ask+ "\n", fh );
}

if (( LastValue(Buy2) == True ) AND alreadyopenbuy2 == "" )
{
StaticVarSetText("alreadyopenbuy2"+Name() , "1");
StaticVarSetText("alreadyopensell2"+Name() , "");

fputs( now(1) + ","+ now(2) + "," + "BUY2" + " ," + Name() + " ," +Ask+ "\n", fh );
}


if (( LastValue(Sell1) == True ) AND alreadyopensell1 == "" )
{
StaticVarSetText("alreadyopenbuy1"+Name() , "");
StaticVarSetText("alreadyopensell1"+Name() , "1");

fputs( now(1) + ","+ now(2) + "," + "SELL1" + " ," + Name() + " ," +Bid+ "\n", fh );
}

if (( LastValue(Sell2) == True ) AND alreadyopensell2 == "" )
{
StaticVarSetText("alreadyopenbuy2"+Name() , "");
StaticVarSetText("alreadyopensell2"+Name() , "1");

fputs( now(1) + ","+ now(2) + "," + "SELL2" + " ," + Name() + " ," +Bid+ "\n", fh );
}
fclose(fh);
}

else

{
_TRACE("Failed to open the file");
}

Is there anything i should add to the above code???

Please guide.

Thanks.
 

mastermind007

Well-Known Member
#16
It is missing few signals (2-3 out of 40, of different scrips different signals)
I am unable to find out the reason, running it on 5 mins intraday data.

below is the code:

alreadyopenbuy1 = StaticVarGetText("alreadyopenbuy1"+Name());
alreadyopenbuy2 = StaticVarGetText("alreadyopenbuy2"+Name());

alreadyopensell1 = StaticVarGetText("alreadyopensell1"+Name());
alreadyopensell2 = StaticVarGetText("alreadyopensell2"+Name());


fh = fopen( "C:\\Users\\test\\Desktop\\tradelog.csv", "a" );

if(fh)
{

if ( (LastValue(Buy1) == True ) AND alreadyopenbuy1 == "" )
{
StaticVarSetText("alreadyopenbuy1"+Name() , "1");
StaticVarSetText("alreadyopensell1"+Name() , "");

fputs( now(1) + ","+ now(2) + "," + "BUY1" + " ," + Name() + " ," +Ask+ "\n", fh );
}

if (( LastValue(Buy2) == True ) AND alreadyopenbuy2 == "" )
{
StaticVarSetText("alreadyopenbuy2"+Name() , "1");
StaticVarSetText("alreadyopensell2"+Name() , "");

fputs( now(1) + ","+ now(2) + "," + "BUY2" + " ," + Name() + " ," +Ask+ "\n", fh );
}


if (( LastValue(Sell1) == True ) AND alreadyopensell1 == "" )
{
StaticVarSetText("alreadyopenbuy1"+Name() , "");
StaticVarSetText("alreadyopensell1"+Name() , "1");

fputs( now(1) + ","+ now(2) + "," + "SELL1" + " ," + Name() + " ," +Bid+ "\n", fh );
}

if (( LastValue(Sell2) == True ) AND alreadyopensell2 == "" )
{
StaticVarSetText("alreadyopenbuy2"+Name() , "");
StaticVarSetText("alreadyopensell2"+Name() , "1");

fputs( now(1) + ","+ now(2) + "," + "SELL2" + " ," + Name() + " ," +Bid+ "\n", fh );
}
fclose(fh);
}

else

{
_TRACE("Failed to open the file");
}

Is there anything i should add to the above code???

Please guide.

Thanks.
Sky is the limit on what you could or could not add.. I am no one to answer that question....
Nevertheless, here are my suggestions

1) Put _TRACE in all if branches...
2) Place "0" in staticvar instead of empty string. I would recommend using literal string "ONE" and "ZERO".

Once all signals are working as expected, tweak (undo mods) the code to figure out the point at
which it stops working correctly again....
 
Last edited:

Similar threads