ok...After trial and error, I have fixed it. I was trying to use 
NewBar_Started=1 inside the if. So I created an array and used lastvalue 
instead.
Current_Timenum=TimeNum();

Previous_Timenum=Ref(TimeNum(),-1);

Newbar_Difference=Current_Timenum-Previous_Timenum;

Newbar_Difference_100=(Newbar_Difference ==100);

"Newbar_Difference is "+Newbar_Difference;

NewBar_Started=IIf(Newbar_Difference_100,1,0);

"NewBar_Started value "+NewBar_Started;

if( LastValue(NewBar_Started) AND LastValue(Ref( Cover,-1) ) )

What this code does is to wait for 1minute after the completion of the most 
recent hourly bar signal and then write the orders to the file. The earlier 
nuance I had was that AA was writing to the file EVERY TIME AA was scanning.

I tried using Alertif to run the vbscript to write orders to a file. 
Unfortunately Alertif doesn't support scripts yet. So this has to be an exe. I 
will submit a reuest to support script launching from alertif on the 
suggestions box. If anyone else thinks it has value, pls chime in on the 
suggestions board.



Thanks.

Cheers,Padhu



  ----- Original Message ----- 
  From: Padhu 
  To: [email protected] ; [EMAIL PROTECTED] 
  Sent: Thursday, September 20, 2007 5:56 PM
  Subject: [amibroker] Need help with setting a variable to 1 if condition is 
matched otherwise set to 0



  Hello,

  I have this into support as well...wondering if anyone can take a stab at 
this on the groups here.

  Basically i want newbar_started to be set to 1 when Newbar_Difference=100 
otherwise set to 0.  I would then like this NewBar_Started=1 to be ANDed inside 
if statement.
   Obviously I am missing something here, so the below code is not working.

  Current_Timenum=TimeNum();
  Previous_Timenum=Ref(TimeNum(),-1);
  Newbar_Difference=Current_Timenum-Previous_Timenum;
  Newbar_Difference_100=(Newbar_Difference =100);
  "Newbar_Difference is "+Newbar_Difference;
  if(( Newbar_Difference ==100) ) NewBar_Started = 1;
  else if ( Newbar_Difference <>100 ) NewBar_Started = 0;
  "NewBar_Started is "+NewBar_Started;

  if(NewBar_Started=1 AND LastValue(Ref( Cover, -1) ) )

  {

  mvOrderOIF = 

  "1"+","+

  Broker_Symbol+

  ","+ "BUYSTOP" + 

  ","+ 2 + 

  ","+ (High+Entry_Offset_For_ScalperTrades) + 

  ","+ (Low-Stop_Offset_For_ScalperTrades) + 

  ","+ (High+-EXIT_Offset_For_ScalperTrades) + 

  "," + ScalperSwing_BuyStrategy_Name;

  thanks,Padhu

   

Reply via email to