Click here to Login





                                                   Monthly/Weekly time Signals

  0

0
moni
2014-09-30 13:14:35


What is the best way to find the first trading day of the week /month through AMM Script
I found basic examples that relay on Monday
For weekly:
if(Divers.CurrentDate.DayOfWeek == DayOfWeek.Monday)

For Mothly :
if(Divers.CurrentDate.Day <= 7 && Divers.CurrentDate.DayOfWeek == DayOfWeek.Monday)

but It's not always the case

moni



QuantShare
2014-10-01 05:30:06

  0

Hi Moni,

You can create a global variable (in Global event) and update it with the current date in the "OnEndPeriod" event.

Global:
DateTime date = DateTime.MinValue;

OnEndPeriod:
using System.Globalization;

int w1 = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
int w2 = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(Divers.CurrentDate, CalendarWeekRule.FirstDay, DayOfWeek.Monday);

if(w1 != w2)
{
// New Week
}

if(date.Month != Divers.CurrentDate.Month)
{
// New Month
}



// Update date
date = Divers.CurrentDate;



moni
2014-10-01 14:32:20

  0

Thanks alot


No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Number of Buy Signals Over Time in a Simulation
Trading Strategy based on the Number of Buy Signals
Time Segmented Volume
Multiple Time Frames Trading System - Price / Moving Average Cros...
Stock Correlation with its Industry - Change over time

How-to Lessons
How to generate buy/sell signals from a trading system
How to detect stocks trading near all time highs
How to calculate the average of a time series using the money man...
How to plot two different time frames in the same chart
How to hide a trading indicator from a particular time frame

Related Forum Threads
Real Time Tick Data
Dynamic Watchlist update for each time step during a simulation?
Time cycle indicators
Real Time experience
Hysteresis in ranking sytem - reduce trading with time decay fact...

Blog Posts
Running QuantShare on Amazon's EC2 Cloud & Automate Strategies Si...
Statistical data analysis of time series
Real Time Alerts: Support and Resistance Lines Breakout
Update Chart Layout based on Active Time Frame
Presentation of QuantShare's new Real Time Version









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.