I have type 1 diabetes and my bsugar has been high for a few days and just now it was 540...What is causing this high sugars?

Change insulin. If you are not ill, then there could be an Insulin delivery problem. If on an Insulin pump, change site and bolus Insulin via needles until bs come down. Check color of insulin, verify expiry date, etc. If ketones are large, you will need medical attention asap .
Most likely diet. As a type 1 diabetic, an elevate blood sugar is most likely due to dietary intake and insufficient dosing of insulin. Do not change your dosing without first consulting your physician. Bring your blood sugar readings into your doctor's office asap for more guidance.